﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace CommunitySystemModel
{
    [Serializable]
    [DataContract]
    public class Emp_BasicInfoModel
    {
        private bool isselected = false;
        [DataMember]
        public bool IsSelected
        {
            get { return isselected; }
            set { isselected = value; }
        }

        private int _Sequence;
        [DataMember]
        public int Sequence
        {
            get { return _Sequence; }
            set { _Sequence = value; }
        }

        private int _ID;
        [DataMember]
        public int ID
        {
            get { return _ID; }
            set { _ID = value; }
        }

        private string _Name = string.Empty;
        [DataMember]
        public string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }

        private string _CardNo = string.Empty;
        [DataMember]
        public string CardNo
        {
            get { return _CardNo; }
            set { _CardNo = value; }
        }
        private string _Gender = string.Empty;
        [DataMember]
        public string Gender
        {
            get { return _Gender; }
            set { _Gender = value; }
        }
        private string _BirthPlace = string.Empty;
        [DataMember]
        public string BirthPlace
        {
            get { return _BirthPlace; }
            set { _BirthPlace = value; }
        }
        private string _HouseholdRegister = string.Empty;
        [DataMember]
        public string HouseholdRegister
        {
            get { return _HouseholdRegister; }
            set { _HouseholdRegister = value; }
        }
        private string _Native = string.Empty;
        [DataMember]
        public string Native
        {
            get { return _Native; }
            set { _Native = value; }
        }
        private string _Political = string.Empty;
        [DataMember]
        public string Political
        {
            get { return _Political; }
            set { _Political = value; }
        }
        private string _Health = string.Empty;
        [DataMember]
        public string Health
        {
            get { return _Health; }
            set { _Health = value; }
        }
        private DateTime? _WorkDate = null;
        [DataMember]
        public DateTime? WorkDate
        {
            get { return _WorkDate; }
            set { _WorkDate = value; }
        }
        private string _RegisterNo = string.Empty;
        [DataMember]
        public string RegisterNo
        {
            get { return _RegisterNo; }
            set { _RegisterNo = value; }
        }
        private string _OrganizationType = string.Empty;
        [DataMember]
        public string OrganizationType
        {
            get { return _OrganizationType; }
            set { _OrganizationType = value; }
        }
        private DateTime? _NowWorkDate = null;
        [DataMember]
        public DateTime? NowWorkDate
        {
            get { return _NowWorkDate; }
            set { _NowWorkDate = value; }
        }
        private string _NativePlace = string.Empty;
        [DataMember]
        public string NativePlace
        {
            get { return _NativePlace; }
            set { _NativePlace = value; }
        }
        private string _Marriage = string.Empty;
        [DataMember]
        public string Marriage
        {
            get { return _Marriage; }
            set { _Marriage = value; }
        }
        private string _HomeAddress = string.Empty;
        [DataMember]
        public string HomeAddress
        {
            get { return _HomeAddress; }
            set { _HomeAddress = value; }
        }
        private string _Phone = string.Empty;
        [DataMember]
        public string Phone
        {
            get { return _Phone; }
            set { _Phone = value; }
        }
        private string _EmpIdentity = string.Empty;
        [DataMember]
        public string EmpIdentity
        {
            get { return _EmpIdentity; }
            set { _EmpIdentity = value; }
        }
        private DateTime? _PartyTime = null;
        [DataMember]
        public DateTime? PartyTime
        {
            get { return _PartyTime; }
            set { _PartyTime = value; }
        }
        private string _Special = string.Empty;
        [DataMember]
        public string Special
        {
            get { return _Special; }
            set { _Special = value; }
        }
        private string _TechnicalPositions = string.Empty;
        [DataMember]
        public string TechnicalPositions
        {
            get { return _TechnicalPositions; }
            set { _TechnicalPositions = value; }
        }
        private string _PersonnelType = string.Empty;
        [DataMember]
        public string PersonnelType
        {
            get { return _PersonnelType; }
            set { _PersonnelType = value; }
        }
        private DateTime? _RegisterDate = null;
        [DataMember]
        public DateTime? RegisterDate
        {
            get { return _RegisterDate; }
            set { _RegisterDate = value; }
        }
        private DateTime? _Birthday = null;
        [DataMember]
        public DateTime? Birthday
        {
            get { return _Birthday; }
            set { _Birthday = value; }
        }

        private int? _OrgID;
        [DataMember]
        public int? OrgID
        {
            get { return _OrgID; }
            set { _OrgID = value; }
        }
        private string _PositionName = string.Empty;
        [DataMember]
        public string PositionName
        {
            get { return _PositionName; }
            set { _PositionName = value; }
        }
        private string _OrgName = string.Empty;
        [DataMember]
        public string OrgName
        {
            get { return _OrgName; }
            set { _OrgName = value; }
        }

        private bool? _HasPhoto = false;
        [DataMember]
        public bool? HasPhoto
        {
            get { return _HasPhoto; }
            set { _HasPhoto = value; }
        }

        private string _PhotoName;
        [DataMember]
        public string PhotoName
        {
            get { return _PhotoName; }
            set { _PhotoName = value; }
        }
        private DateTime? _TuiXiuDate = null;
        [DataMember]
        public DateTime? TuiXiuDate
        {
            get { return _TuiXiuDate; }
            set { _TuiXiuDate = value; }
        }
        private int? _JuTuiXiuDate = 0;
        [DataMember]
        public int? JuTuiXiuDate
        {
            get { return _JuTuiXiuDate; }
            set { _JuTuiXiuDate = value; }
        }
        private string _HuoDeFangShi = string.Empty;
        [DataMember]
        public string HuoDeFangShi
        {
            get { return _HuoDeFangShi; }
            set { _HuoDeFangShi = value; }
        }


        private string _DutyNo = string.Empty;
        [DataMember]
        public string DutyNo
        {
            get { return _DutyNo; }
            set { _DutyNo = value; }
        }
        private string _DutyName = string.Empty;
        [DataMember]
        public string DutyName
        {
            get { return _DutyName; }
            set { _DutyName = value; }
        }
        private string _DutyLevel = string.Empty;
        [DataMember]
        public string DutyLevel
        {
            get { return _DutyLevel; }
            set { _DutyLevel = value; }
        }
        private string _DutyAttribute = string.Empty;
        [DataMember]
        public string DutyAttribute
        {
            get { return _DutyAttribute; }
            set { _DutyAttribute = value; }
        }
        private DateTime? _OKDate = null;
        [DataMember]
        public DateTime? OKDate
        {
            get { return _OKDate; }
            set { _OKDate = value; }
        }
        private string _ServiceMode = string.Empty;
        [DataMember]
        public string ServiceMode
        {
            get { return _ServiceMode; }
            set { _ServiceMode = value; }
        }
        private DateTime? _JobDate = null;
        [DataMember]
        public DateTime? JobDate
        {
            get { return _JobDate; }
            set { _JobDate = value; }
        }
        private string _RXRZWSXSJ = string.Empty;
        [DataMember]
        public string RXRZWSXSJ
        {
            get { return _RXRZWSXSJ; }
            set { _RXRZWSXSJ = value; }
        }
        private string _EducationName = string.Empty;
        [DataMember]
        public string EducationName
        {
            get { return _EducationName; }
            set { _EducationName = value; }
        }
        private string _EducationType = string.Empty;
        [DataMember]
        public string EducationType
        {
            get { return _EducationType; }
            set { _EducationType = value; }
        }
        private DateTime? _GraduationDate = null;
        [DataMember]
        public DateTime? GraduationDate
        {
            get { return _GraduationDate; }
            set { _GraduationDate = value; }
        }
        private string _School = string.Empty;
        [DataMember]
        public string School
        {
            get { return _School; }
            set { _School = value; }
        }
        private string _Professional = string.Empty;
        [DataMember]
        public string Professional
        {
            get { return _Professional; }
            set { _Professional = value; }
        }
        private string _EmpStatus = "在职";
        [DataMember]
        public string EmpStatus
        {
            get { return _EmpStatus; }
            set { _EmpStatus = value; }
        }
        private string _TuiXiuDateString = string.Empty;
        [DataMember]
        public string TuiXiuDateString
        {
            get { return _TuiXiuDateString; }
            set { _TuiXiuDateString = value; }
        }
        private DateTime? _StatusDate = null;
        [DataMember]
        public DateTime? StatusDate
        {
            get { return _StatusDate; }
            set { _StatusDate = value; }
        }
        private string _DegreeGraduation = null;
        [DataMember]
        public string DegreeGraduation
        {
            get { return _DegreeGraduation; }
            set { _DegreeGraduation = value; }
        }
        public static Emp_BasicInfoModel FillEntity(DataRow dr)
        {
            Emp_BasicInfoModel right = new Emp_BasicInfoModel();
            right.IsSelected = dr["IsSelected"].ToString() == "false" ? false : true;
            right.Sequence = Convert.ToInt32(dr["Sequence"]);
            right.ID = (int) dr["ID"];
            right.Name = dr["Name"] as string;
            right.CardNo = dr["CardNo"] as string;
            right.Gender = dr["Gender"] as string;
            right.BirthPlace = dr["BirthPlace"] as string;
            right.HouseholdRegister = dr["HouseholdRegister"] as string;
            right.Native = dr["Native"] as string;
            right.Political = dr["Political"] as string;
            right.Health = dr["Health"] as string;
            right.WorkDate = string.IsNullOrEmpty(dr["WorkDate"].ToString())?null: (DateTime?)dr["WorkDate"];
            right.RegisterNo = dr["RegisterNo"] as string;
            right.OrganizationType = dr["OrganizationType"] as string;
            right.NowWorkDate = string.IsNullOrEmpty(dr["NowWorkDate"].ToString()) ? null : (DateTime?)dr["NowWorkDate"];
            right.NativePlace = dr["NativePlace"] as string;
            right.Marriage = dr["Marriage"] as string;
            right.HomeAddress = dr["HomeAddress"] as string;
            right.Phone = dr["Phone"] as string;
            right.EmpIdentity = dr["EmpIdentity"] as string;
            right.PartyTime = string.IsNullOrEmpty(dr["PartyTime"].ToString()) ? null : (DateTime?)dr["PartyTime"];
            right.Special = dr["Special"] as string;
            right.TechnicalPositions = dr["TechnicalPositions"] as string;
            right.PersonnelType = dr["PersonnelType"] as string;
            right.RegisterDate = string.IsNullOrEmpty(dr["RegisterDate"].ToString()) ? null : (DateTime?)dr["RegisterDate"];
            right.Birthday = string.IsNullOrEmpty(dr["Birthday"].ToString()) ? null :  (DateTime?)dr["Birthday"];
            if (!string.IsNullOrEmpty(dr["OrgID"].ToString())) right.OrgID = (int?)dr["OrgID"];
            right.PositionName = dr["PositionName"] as string;
            right.OrgName = dr["OrgName"] as string;
            if (dr.Table!= null && dr.Table.Columns.Contains("HasPhoto"))
                right.HasPhoto = dr["HasPhoto"] as bool?;
            if (dr.Table != null && dr.Table.Columns.Contains("PhotoName"))
                right.PhotoName = dr["PhotoName"] as string;
            if (dr.Table != null && dr.Table.Columns.Contains("DegreeGraduation"))
                right.DegreeGraduation = dr["DegreeGraduation"] as string;
            if (dr.Table != null && dr.Table.Columns.Contains("TuiXiuDate")) if (!string.IsNullOrEmpty(dr["TuiXiuDate"].ToString())) right.TuiXiuDate = Convert.ToDateTime(dr["TuiXiuDate"]);
            if (dr.Table != null && dr.Table.Columns.Contains("JuTuiXiuDate")) if (!string.IsNullOrEmpty(dr["JuTuiXiuDate"].ToString())) right.JuTuiXiuDate = (int?)dr["JuTuiXiuDate"];
            if (dr.Table != null && dr.Table.Columns.Contains("HuoDeFangShi")) if (!string.IsNullOrEmpty(dr["HuoDeFangShi"].ToString())) right.HuoDeFangShi = dr["HuoDeFangShi"].ToString();

            if (dr.Table != null && dr.Table.Columns.Contains("DutyNo")) if (!string.IsNullOrEmpty(dr["DutyNo"].ToString())) right.DutyNo = dr["DutyNo"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("DutyName")) if (!string.IsNullOrEmpty(dr["DutyName"].ToString())) right.DutyName = dr["DutyName"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("DutyLevel")) if (!string.IsNullOrEmpty(dr["DutyLevel"].ToString())) right.DutyLevel = dr["DutyLevel"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("DutyAttribute")) if (!string.IsNullOrEmpty(dr["DutyAttribute"].ToString())) right.DutyAttribute = dr["DutyAttribute"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("OKDate")) if (!string.IsNullOrEmpty(dr["OKDate"].ToString())) right.OKDate = (DateTime?)dr["OKDate"];
            if (dr.Table != null && dr.Table.Columns.Contains("ServiceMode")) if (!string.IsNullOrEmpty(dr["ServiceMode"].ToString())) right.ServiceMode = dr["ServiceMode"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("JobDate")) if (!string.IsNullOrEmpty(dr["JobDate"].ToString())) right.JobDate = (DateTime?)dr["JobDate"];
            if (dr.Table != null && dr.Table.Columns.Contains("RXRZWSXSJ")) if (!string.IsNullOrEmpty(dr["RXRZWSXSJ"].ToString())) right.RXRZWSXSJ = dr["RXRZWSXSJ"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("EducationName")) if (!string.IsNullOrEmpty(dr["EducationName"].ToString())) right.EducationName = dr["EducationName"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("EducationType")) if (!string.IsNullOrEmpty(dr["EducationType"].ToString())) right.EducationType = dr["EducationType"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("GraduationDate")) if (!string.IsNullOrEmpty(dr["GraduationDate"].ToString())) right.GraduationDate = (DateTime?)dr["GraduationDate"];
            if (dr.Table != null && dr.Table.Columns.Contains("School")) if (!string.IsNullOrEmpty(dr["School"].ToString())) right.School = dr["School"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("Professional")) if (!string.IsNullOrEmpty(dr["Professional"].ToString())) right.Professional = dr["Professional"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("EmpStatus")) if (!string.IsNullOrEmpty(dr["EmpStatus"].ToString())) right.EmpStatus = dr["EmpStatus"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("TuiXiuDateString")) if (!string.IsNullOrEmpty(dr["TuiXiuDateString"].ToString())) right.TuiXiuDateString = dr["TuiXiuDateString"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("StatusDate")) if (!string.IsNullOrEmpty(dr["StatusDate"].ToString())) right.StatusDate = (DateTime?)dr["StatusDate"];
            return right;
        }
    }
}
